﻿(function ($) {
    $.fn.textFocus = function (v) {
        var range, len, v = v === undefined ? 0 : parseInt(v);
        this.each(function () {
            //if ($.browser.msie) {
            //    range = this.createTextRange(); //文本框创建范围 
            //    v === 0 ? range.collapse(false) : range.move("character", v); //范围折叠 
            //    range.select(); //选中 
            //} else {
                len = this.value.length;
                v === 0 ? this.setSelectionRange(len, len) : this.setSelectionRange(v, v); //dom直接设置选区，然后focus 
            //}
            this.focus();
        });
        return this;
    }
})(jQuery) 
